<template>
  <div class="header">
    <div class="header-left">
      <span class="iconfont">&#xe8ef;</span>
    </div>
    <div class="header-input">
      <span class="iconfont">&#xe8b8; </span>
      输入城市/景点/游玩主题
    </div>
    <router-link to="/city">
      <div class="header-right">
        {{ this.$store.state.city }}
        <span class="iconfont icon-arrow"> &#xe8f7;</span>
      </div>
    </router-link>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "HomeHeader",
  data() {
    return {};
  },
  methods: {
    loadData() {
      axios
        .get("http://localhost:3000/cityList")
        .then((res) => {
          this.city = res.data.city;
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  mounted() {
    this.loadData();
  },
};
</script>


<style lang='stylus' scoped>
.header {
  height: 0.86rem;
  line-height: 0.86rem;
  color: #fff;
  background: #00bcd4;
  display: flex;
}

.header-left {
  width: 0.64rem;
  float: left;
}

.header-input {
  margin-top: 0.12rem;
  line-height: 0.64rem;
  height: 0.64rem;
  margin-left: 0.12rem;
  flex: 1;
  background: #fff;
  border-radius: 0.1rem;
  text-align: left;
  color: #ccc;
}

.header-right {
  color: #fff;
  padding: 0 0.1rem;
  min-width: 1.04rem;
  float: right;
  text-align: center;
}

.icon-arrow {
  margin-left: -0.1rem;
}
</style>